package TAIC.feature;

import java.io.File;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class ClusterStat {

	static public void main ( String args [ ]) throws Exception {
		if ( args.length != 1 ) {
			System.out.println ( "please input the folder");
			return ; 
		}
		
		Scanner scanner = new Scanner ( new File ( args[0] + "\\mat.clustering.400" )) ;
		int count []  = new int [ 401 ] ;
		while ( scanner.hasNextInt () ) 
			count [ scanner.nextInt() + 1 ] ++ ;
		scanner.close(); 
		
		Node[] arr = new Node [ 401 ] ;		
		for ( int i = 0; i < 401 ; i ++ ) arr[ i ] = new Node ( i, count[ i ])  ;
		scanner.close(); 
		Arrays.sort( arr);
		
		PrintStream fout = new PrintStream ( new File ( args[0] + "\\mat.stat")) ;
		for ( int i = 0 ; i < arr.length ; i ++ ) fout.println ( (arr[i].index - 1 ) + " " + arr[ i ].value );
		fout.close() ;
	}
	
}

